$(function () {
    var chart_datagrid = $("#chart_datagrid");
    var chart_dialog = $("#chart_dialog");
    var chart_form = $("#chart_form");
    chart_datagrid.datagrid({
        url: '/charts/formalStudent.do',
        fit: true,
        fitColumns: true,
        columns: [[
            {field: 'groupType', title: '分组类型', width: 100,formatter:function (value) {
                if(value == 32){
                    return '微信';
                }else if(value == 33){
                    return '支付宝';
                }else if(value == 34){
                    return '网银';
                }else if(value == 35){
                    return '借贷';
                }else if(value == 0){
                    return '正常';
                }else if(value == 1){
                    return '转班';
                }else if(value == 2){
                    return '流失';
                }
            }},
            {field: 'totalPaid', title: '已付总款', width: 100},
            {
                field: 'debt', title: '未付总款', width: 100
            },
        ]],
        singleSelect: true,
        pagination: true,
        toolbar: "#chart_btns",
        rownumbers:true
    });
    var methodObj = {
        reload: function () {
            chart_datagrid.datagrid('reload',[]);
        },
        query:function () {
            var keyword = $("[name=keyword]").val();
            var beginDate = $("[name=beginDate]").val();
            var endDate = $("[name=endDate]").val();
            var groupBy = $("[name=groupBy]").val();
            $.post('/charts/formalStudent.do',{keyword:keyword,beginDate:beginDate,endDate:endDate,groupBy:groupBy},function (data) {
                console.log(data);
                chart_datagrid.datagrid('loadData',data);
            })
        }
    }

    $("a[data-cmd]").click(function () {
        var methodName = $(this).data('cmd');
        methodObj[methodName]();
    })
})



